import pandas as pd
from bokeh.colors.groups import orange
from matplotlib import pyplot as plt
import  matplotlib.ticker as ticker
plt.rcParams['font.sans-serif']=['SimHei']
city_ai_salary=[]
my_list=['成都','西安','北京','杭州','上海','南京','武汉','深圳','广州']
for address in my_list:
    data = pd.read_excel(f"./data4_4_classify_job/人工智能{address}.xlsx")
    data1=data.drop('Unnamed: 0',axis=1)
    salary_average = int(data1['salary'].mean())
    city_ai_salary.append(salary_average)
data_new = pd.DataFrame({'城市名称':my_list,
                         '平均工资':city_ai_salary})
data_new = data_new.sort_values(by='平均工资',ascending=False)
data_new = data_new.reset_index(drop=True)
colors=['g','r','b','c','m','y','k','orange','purple','brown']
data_new.plot(kind='bar',x='城市名称',y='平均工资',width=0.5,color=colors)
average_salary = data_new['平均工资'].tolist()
for x,y in enumerate(average_salary):
    plt.text(x,y,y,ha='center',fontsize=12)
plt.ylim(12000,20000)
plt.title('罗坛作业：全国城市人工智能岗位平均工资排序')
plt.xlabel('城市名称',fontsize=16)
plt.ylabel('平均工资',fontsize=16)
plt.xticks(fontsize=10,rotation=0)
plt.tight_layout()
plt.savefig('./picture/5-3.全国城市人工智能岗位平均工资排序.png')
plt.show()